<template>
	<view>
		<dsl-navbar title="设置" bgTopImg="white" isBack=""></dsl-navbar>
		<view class="bg-white padding solid-bottom justify-between" @click="setting(1)">
			<text>绑定账号</text>
			<text class="cuIcon-right"></text>
		</view>
		<view class="bg-white padding solid-bottom justify-between" @click="setting(2)">
			<text>视频清晰度</text>
			<text>
				<text class="text-gray">
					默认
				</text>
				<text class="cuIcon-right margin-left"></text>
			</text>
		</view>
		<view class="bg-white padding solid-bottom justify-between" @click="setting(3)">
			<text>黑名单</text>
			<text class="cuIcon-right"></text>
		</view>

	<!-- 	<view class="bg-white margin-top padding solid-bottom justify-between" @click="setting(4)">
			<text>通知设置</text>
			<text class="cuIcon-right"></text>
		</view> -->
		<!-- <view class="bg-white margin-bottom padding solid-bottom justify-between" @click="setting(5)">
			<text>隐私设置</text>
			<text class="cuIcon-right"></text>
		</view> -->
		<view class="bg-white padding margin-top solid-bottom justify-between" @click="$tools.showToast('缓存已清除')">
			<text>清除缓存</text>
			<text>
				<text class="text-gray">
					0.00MB
				</text>
				<text class="cuIcon-right margin-left"></text>
			</text>
		</view>
		<view class="bg-white  padding solid-bottom justify-between" @click="messageOut()">
			<text>清楚聊天记录</text>
			<text class="cuIcon-right"></text>
		</view>
	<!-- 	<view class="bg-white  padding solid-bottom justify-between">
			<text>想幻评价</text>
			<text class="cuIcon-right"></text>
		</view> -->
		<view class="bg-white  padding solid-bottom justify-between" @click="$tools.push('/pages/plugins/agreement?id=0')">
			<text>用户协议</text>
			<text class="cuIcon-right"></text>
		</view>
		<view class="bg-white  padding solid-bottom justify-between" @click="$tools.push('/pages/plugins/agreement?id=1')">
			<text>隐私协议</text>
			<text class="cuIcon-right"></text>
		</view>
		<view class="bg-white  padding solid-bottom justify-between" @click="$tools.push('/pages/plugins/agreement?id=2')">
			<text>关于我们</text>
			<text class="cuIcon-right"></text>
		</view>

		<view class="bg-white margin-top margin-bottom padding solid-bottom justify-between" @click="settingOut()">
			<text>退出登录</text>
			<text class="cuIcon-right"></text>
		</view>


	</view>
</template>

<script>
	import {
		mapState,
		mapActions
	} from 'vuex'
	export default {
		data() {
			return {

			}
		},
		//生命周期函数
		onReady() {},
		onLoad() {},
		onShow() {},
		methods: {
			//removeMessage 清除聊天记录
			...mapActions('chat', ['removeMessage']),
			
			
			//清除聊天记录
			messageOut() {
				let v = this
				uni.showActionSheet({
					itemList: ['清除全部聊天记录'],
					success: function(res) {
						if (res.tapIndex == 0) {
							v.removeMessage({
								idList:''
							})
						} else {}
					},
					fail: function(res) {
						console.log(res.errMsg);
					}
				});

			},

			//设置
			setting(event) {
				if (event == 1) {
					//绑定账号
					uni.navigateTo({
						url: '/pages/user/modules/withdraw/withdrawBinding'
					})
					return
				}

				if (event == 2) {
					//视频清晰度
					uni.showActionSheet({
						itemList: ['超清720P', '高清540P'],
						success: function(res) {
							if (res.tapIndex == 0) {} else {}
						},
						fail: function(res) {
							console.log(res.errMsg);
						}
					});
					return
				}
				if (event == 3) {
					//黑名单
					uni.navigateTo({
						url: '/pages/message/blacklist'
					})
					return
				}
				if (event == 4) {
					uni.navigateTo({
						url: '/pages/userInfo/modules/setting/informSetting'
					})
					return
				}
				if (event == 5) {
					uni.navigateTo({
						url: '/pages/userInfo/modules/setting/privacySetting'
					})
					return
				}
			},
			//退出登录
			settingOut() {
				let that = this
				uni.showActionSheet({
					itemList: ['退出登录'],
					success: function(res) {
						if (res.tapIndex == 0) {
							uni.clearStorageSync()
							that.$tools.showToast('退出成功')
							setTimeout(() => {
								uni.reLaunch({
									url: '/pages/login/login'
								})
							}, 1000)
						}
					},
					fail: function(res) {
						console.log(res.errMsg);
					}
				});
			}
		},
		computed: {},
		components: {}
	}
</script>

<style>
	page {
		background: #F7F6FA;
	}
</style>
